package com.example.common.utils;

import com.example.common.entity.member.MemberEntity;
import com.example.common.to.cart.UserInfoTo;

/**
 * <p>
 *
 * </p>
 *
 * @author zyred
 * @since v 0.1
 **/
public class GuLiMallThreadLocalPool {

    private final static ThreadLocal<UserInfoTo> users = new ThreadLocal<>();

    public static void setUsers(UserInfoTo info) {
        users.set(info);
    }

    public static UserInfoTo getUsers () {
        return users.get();
    }

    public static UserInfoTo getRemove () {
        UserInfoTo info = users.get();
        users.remove();
        return info;
    }


    private static final ThreadLocal<MemberEntity> member = new ThreadLocal<>();

    public static void setMember(MemberEntity info) {
        member.set(info);
    }

    public static MemberEntity getMember () {
        return member.get();
    }

    public static MemberEntity getMemberRemove () {
        MemberEntity info = member.get();
        users.remove();
        return info;
    }
    public static void removeMember () {
        users.remove();
    }
}
